home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / System / XADmaster / xad_dev / Sources / clients / xadIO.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-04-01  |  4.4 KB  |  114 lines

  1. #ifndef XADMASTER_XADIO_H
  2. #define XADMASTER_XADIO_H
  3.  
  4. /* Programmheader
  5.  
  6.     Name:        xadIO.h
  7.     Main:        xadmaster
  8.     Versionstring:    $VER: xadIO.h 1.4 (24.03.2001)
  9.     Author:        SDI
  10.     Distribution:    Freeware
  11.     Description:    input/output function header
  12.  
  13.  1.0   16.03.00 : first version
  14.  1.1   23.10.00 : added XIDFLAG_REACHEDEND
  15.  1.2   24.10.00 : renamed from xadInput.h
  16.  1.3   07.11.00 : moved xadIOPutChar, xadIOGetChar into structure to
  17.     support different functions
  18.  1.4   24.03.01 : added ReadBits versions
  19. */
  20.  
  21. #include <exec/types.h>
  22. #include <proto/xadmaster.h>
  23.  
  24. /* These are used to keep they in sync when called in source directly mode */
  25. #ifndef XADIODIRECTMODE
  26. #define XADIOFUNCMODE     extern
  27. #define XADIOFUNCMODEBITS extern
  28. #endif
  29.  
  30. typedef void (*XADINOUTFUNC)(struct xadInOut *io, ULONG size);
  31. typedef UBYTE (*XADINOUTPUT)(struct xadInOut *io, UBYTE data);
  32. typedef UBYTE (*XADINOUTGET)(struct xadInOut *io);
  33.  
  34. struct xadInOut {
  35.   struct xadArchiveInfo * xio_ArchiveInfo;        /* filled by xadIOAlloc */
  36.   struct xadMasterBase *  xio_xadMasterBase;        /* filled by xadIOAlloc */
  37.   LONG              xio_Error;            /* cleared */
  38.   ULONG              xio_Flags;            /* filled by xadIOAlloc, functions or user */
  39.  
  40.   XADINOUTGET          xio_GetFunc;            /* filled by xadIOAlloc or user */
  41.   APTR              xio_GetFuncPrivate;
  42.   XADINOUTPUT          xio_PutFunc;            /* filled by xadIOAlloc or user */
  43.   APTR              xio_PutFuncPrivate;
  44.  
  45.   XADINOUTFUNC              xio_InFunc;
  46.   APTR              xio_InFuncPrivate;
  47.   ULONG                   xio_InSize;
  48.   ULONG              xio_InBufferSize;
  49.   ULONG              xio_InBufferPos;
  50.   STRPTR          xio_InBuffer;
  51.   ULONG              xio_BitBuf;            /* for xadIOGetBits functions */
  52.   UWORD              xio_BitNum;            /* for xadIOGetBits functions */
  53.  
  54.   UWORD              xio_CRC16;            /* crc16 from output functions */
  55.   ULONG              xio_CRC32;            /* crc32 from output functions */
  56.  
  57.   XADINOUTFUNC              xio_OutFunc;
  58.   APTR              xio_OutFuncPrivate;
  59.   ULONG                   xio_OutSize;
  60.   ULONG              xio_OutBufferSize;
  61.   ULONG              xio_OutBufferPos;
  62.   STRPTR          xio_OutBuffer;
  63. };
  64.  
  65. /* setting BufferPos to buffer size activates first time read! */
  66.  
  67. #define XADIOF_ALLOCINBUFFER    (1<<0)    /* allocate input buffer */
  68. #define XADIOF_ALLOCOUTBUFFER    (1<<1)    /* allocate output buffer */
  69. #define XADIOF_NOINENDERR    (1<<2)    /* xadIOGetChar does not produce err at buffer end */
  70. #define XADIOF_NOOUTENDERR      (1<<3)  /* xadIOPutChar does not check out size */
  71. #define XADIOF_LASTINBYTE       (1<<4)  /* last byte was read, set by xadIOGetChar */
  72. #define XADIOF_LASTOUTBYTE      (1<<5)  /* output length was reached, set by xadIOPutChar */
  73. #define XADIOF_ERROR            (1<<6)    /* an error occured */
  74. #define XADIOF_NOCRC16        (1<<7)  /* calculate no CRC16 */
  75. #define XADIOF_NOCRC32        (1<<8)  /* calculate no CRC32 */
  76. #define XADIOF_COMPLETEOUTFUNC    (1<<9)    /* outfunc completely replaces write stuff */
  77.  
  78. /* allocates the xadInOut structure and the buffers */
  79. XADIOFUNCMODE struct xadInOut *xadIOAlloc(ULONG flags, struct xadArchiveInfo *ai, struct xadMasterBase *xadMasterBase);
  80.  
  81. /* writes the buffer out */
  82. XADIOFUNCMODE LONG xadIOWriteBuf(struct xadInOut *io);
  83.  
  84. #define xadIOGetChar(io)    (io)->xio_GetFunc((io))        /* reads one byte */
  85. #define xadIOPutChar(io,a)    (io)->xio_PutFunc((io), (a))    /* stores one byte */
  86.  
  87. /* The read bits function only read the bits without flushing from buffer. This is
  88. done by DropBits. Some compressors need this method, as the flush different amount
  89. of data than they read in. Normally the GetBits functions are used.
  90. When including the source file directly, do not forget to set the correct defines
  91. to include the necessary functions. */
  92.  
  93. #if !defined(XADIODIRECTMODE) || defined(XADIOGETBITSLOW)
  94. /* new bytes inserted from left, get bits from right end, max 32 bits, no checks */
  95. XADIOFUNCMODEBITS ULONG xadIOGetBitsLow(struct xadInOut *io, UBYTE bits);
  96. #endif
  97.  
  98. #if !defined(XADIODIRECTMODE) || defined(XADIOREADBITSLOW)
  99. XADIOFUNCMODEBITS ULONG xadIOReadBitsLow(struct xadInOut *io, UBYTE bits);
  100. XADIOFUNCMODEBITS void xadIODropBitsLow(struct xadInOut *io, UBYTE bits);
  101. #endif
  102.  
  103. #if !defined(XADIODIRECTMODE) || defined(XADIOGETBITSHIGH)
  104. /* new bytes inserted from right, get bits from left end, max 32 bits, no checks */
  105. XADIOFUNCMODEBITS ULONG xadIOGetBitsHigh(struct xadInOut *io, UBYTE bits);
  106. #endif
  107.  
  108. #if !defined(XADIODIRECTMODE) || defined(XADIOREADBITSHIGH)
  109. XADIOFUNCMODEBITS ULONG xadIOReadBitsHigh(struct xadInOut *io, UBYTE bits);
  110. XADIOFUNCMODEBITS void xadIODropBitsHigh(struct xadInOut *io, UBYTE bits);
  111. #endif
  112.  
  113. #endif /* XADMASTER_XADIO_H */
  114.